package com.cqsw.controller;

import com.cqsw.model.Result;
import com.cqsw.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Classname UserController
 * @Description TODO
 * @Date 2022/6/13 14:20
 * @Created by Smith.Liu
 */
@RestController
@RequestMapping("/users")
@CrossOrigin
public class UserController {
    private final UserService userService;

    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    /**
     * {
     * "code": 200,
     * "msg": "查询成功",
     * "data": [{
     * "id": 1,
     * "birthday": "2022-06-13",
     * "gender": "女",
     * "username": "xiaoliu",
     * "password": "{noop}123456",
     * "remark": null,
     * "state": null,
     * "details": null,
     * "email": null,
     * "roles": null
     * }, {
     * "id": 3,
     * "birthday": "2022-06-12",
     * "gender": "男",
     * "username": "admin",
     * "password": "{noop}123",
     * "remark": null,
     * "state": 0,
     * "details": null,
     * "email": "1713612859@qq.com",
     * "roles": null
     * }, {
     * "id": 5,
     * "birthday": "2022-06-12",
     * "gender": "男",
     * "username": "tomas",
     * "password": "{noop}123",
     * "remark": "tom",
     * "state": 1,
     * "details": null,
     * "email": "1713612859@qq.com",
     * "roles": null
     * }]
     * }
     *
     * @return Result
     */
    @GetMapping
    @CrossOrigin
    public Result getAllUser() {
        return new Result(200, "查询成功", userService.getAllUser());
    }
}
